package cn.arts.assumejson.algo.utils;

/**
 * @author by <a href="mailto:ligang941012@gmail.com">gang.Li</a>
 * @since 2024/7/29 0:17
 */
public class AlgoUtil<T> {

    /**
     * swap two elements;And make sure that the two numbers are not the same number in memory
     *
     * @param a the first element
     * @param b the second element
     */
    public static void swap(int a, int b) {
        a = a ^ b;
        b = a ^ b;
        a = a ^ b;
    }

    public static void swap(int[] arr, int i, int j) {
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
}
